package com.testmanager.testmananger.zyyc.interTest.mapper;

import com.testmanager.testmananger.zyyc.interTest.domain.CaseTestResultEntity;
import com.testmanager.testmananger.zyyc.interTest.domain.CaseTestResultOutputEntity;
import com.testmanager.testmananger.zyyc.interTest.domain.SuiteResultEntity;
import com.testmanager.testmananger.zyyc.interTest.dto.CaseTestResultDto;

/**
 * @description:
 * @author: 何森存
 * @time: 2021/7/23 下午2:05
 */
public class CaseTestResultMapper {

//    private long id;
//
//    private long no;
//    private long caseNo;
//    private String suiteName;
//    private long suiteNo;
//    private String caseName;
//
//    private String output;
//
//    private String parameters;
//    private int status;  // 成功 失败  未执行  int SUCCESS = 1;  FAILURE = 2; SKIP = 3; SUCCESS_PERCENTAGE_FAILURE = 4;
//    private LocalDateTime startTime;
//    private LocalDateTime endTime;


    public static CaseTestResultDto toCaseTestResultDto(CaseTestResultEntity entity, SuiteResultEntity suiteEntity){

        return new CaseTestResultDto()
                .setId(entity.getId())
                .setNo(entity.getNo())
                .setCaseNo(entity.getCaseNo())
                .setSuiteName(suiteEntity.getSuiteName())
                .setSuiteNo(entity.getSuiteNo())
                .setCaseName(entity.getCaseName())
                .setParameters(entity.getParameters())
                .setStatus(entity.getStatus().getValue())
                .setStartTime(entity.getStartTime())
                .setEndTime(entity.getEndTime());
    }
    public static CaseTestResultDto toCaseTestResultDto(CaseTestResultEntity entity, SuiteResultEntity suiteEntity, CaseTestResultOutputEntity output){

        return new CaseTestResultDto()
                .setId(entity.getId())
                .setNo(entity.getNo())
                .setCaseNo(entity.getCaseNo())
                .setSuiteName(suiteEntity.getSuiteName())
                .setSuiteNo(entity.getSuiteNo())
                .setCaseName(entity.getCaseName())
                .setParameters(entity.getParameters())
                .setStatus(entity.getStatus().getValue())
                .setStartTime(entity.getStartTime())
                .setOutput(output.getOutput())
                .setEndTime(entity.getEndTime());
    }

}
